package salt

import (
	"bytes"
	"fmt"
	"math/rand"
	"strconv"
	"time"
)

func SaltInt(n int) int {
	rand.Seed(time.Now().UnixNano())
	y := ""
	for i := 0; i < n; i++ {
		y = fmt.Sprintf("%v%v", y, 9)
	}
	z, _ := strconv.Atoi(y)
	return rand.Intn(z) //生成随机整数
}

func SaltStr(n int) string {
	const char = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
	rand.Seed(time.Now().UnixNano()) // 产生随机种子
	var s bytes.Buffer
	for i := 0; i <= n; i++ {
		s.WriteByte(char[rand.Int63()%int64(len(char))])
	}
	return s.String()
}
